package it.kion.util.ui.ulog2.editor;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.rules.*;

public class PropertiesPartitionScanner
   extends RuleBasedPartitionScanner
{
   public final static String LOG4J_COMMENT = "__log4j_comment";
   public final static String LOG4J_VALUE = "__log4j_value";

   public PropertiesPartitionScanner()
   {
      super();

      Token commentPartition = new Token(LOG4J_COMMENT);
      Token valuePartition = new Token(LOG4J_VALUE);

      SingleLineRule commentRule =
         new SingleLineRule(
            "#",
            null,
            commentPartition,
            (char) 0,
            true);
      commentRule.setColumnConstraint(0);

      SingleLineRule valueRule =
         new SingleLineRule(
            "=",
            null,
            valuePartition,
            (char) 0,
            true);

      setPredicateRules(
         new IPredicateRule[] { commentRule, valueRule });
   }
   
   public static String[] getLegalContentTypes()
   {
      return new String[] {
         IDocument.DEFAULT_CONTENT_TYPE,
         PropertiesPartitionScanner.LOG4J_COMMENT,
         PropertiesPartitionScanner.LOG4J_VALUE };
   }
}
